package com.czk.ioc.lifecircle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/11/22 14:10
 */
public class LifeCircle implements BeanNameAware, BeanFactoryAware, ApplicationContextAware {
    private String name;

    public LifeCircle() {
        System.out.println("第一步：调用无参构造方法");
    }

    public void setName(String name) {
        this.name = name;
        System.out.println("第二步，赋值");
    }
    public void initMethod(){
        System.out.println("第三步：z执行初始化方法");
    }
    public void doSome(){
        System.out.println("第四部：获取实例并使用");
    }
    public void  destroy(){
        System.out.println("第五步：调用销毁方法");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("执行BeanNameAware的setbeanName方法");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("执行BeanFactoryAware的setBeanFactory方法");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("执行ApplicationContextAware的applicationContext方法");
    }
}
